﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using PServiceBus.Services.Gateway.Runtime;

namespace PServiceBus.Workflow.Activities {

    public sealed class RegisterESBTopic<TTopic> : CodeActivity where TTopic : class {

        [RequiredArgument]
        public InArgument<string> ESBEndpointAddress { get; set; }

        protected override void Execute(CodeActivityContext context) {
            var endpointAddress = context.GetValue(ESBEndpointAddress);
            ESB.Connect(endpointAddress);
            Topic.Register<TTopic>();
        }
    }
}
